const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');

const options = {
  definition: {
    openapi: '3.0.0',
    info: {
      title: '指间联盟 API',
      version: '1.0.0',
      description: '指间联盟服务端 API 文档',
      contact: {
        name: 'API Support',
        email: 'support@fingertipalliance.com'
      }
    },
    servers: [
      {
        url: 'http://localhost:3000',
        description: '开发服务器'
      }
    ],
    components: {
      securitySchemes: {
        bearerAuth: {
          type: 'http',
          scheme: 'bearer',
          bearerFormat: 'JWT'
        }
      }
    }
  },
  apis: ['./router.js'], // 指定包含 Swagger 注解的文件路径
};

const specs = swaggerJsdoc(options);

// Swagger UI 配置选项
const swaggerOptions = {
  docExpansion: 'list', // 默认只展开接口标题
  defaultModelsExpandDepth: 2,
  defaultModelExpandDepth: 2
};

module.exports = {
  swaggerUi,
  specs,
  swaggerOptions
};
